#ifndef __OLED_H
#define __OLED_H

#define OLED_I2C_GPIO_PORT GPIOB 
#define OLED_I2C_SCL GPIO_PIN_8
#define OLED_I2C_SDA GPIO_PIN_9
#define OLED_SLAVE_ADDR 0x78

#define OLED_SET_DISPLAY_OFF 0xAE       /* 关闭显示 */
#define OLED_SET_DISPLAY_ON 0xAF        /* 开启显示 */
#define OLED_SET_NORMAL_INVERSE_DISPLAY 0xA6    /* 设置一次为正常显示，再设置为倒转显示 */
#define OLED_SET_MULTPLEX_RATIO 0xA8    /* 设置多用复用率 */
#define OLED_SET_DISPLAY_OFF_SET 0xD3   /* 设置显示偏移 */
#define OLED_SET_COM_PIN_CONF   0xDA    /* 设置COM引脚硬件配置 */
#define OLED_SET_VCOMNH_DESELECT 0xDB   /* 设置VCOMH取消选择级别 */
#define OLED_SET_ENTIRE_DISPLAY_ON 0xA4     /* 设置整个显示打开 */
#define OLED_SET_ENTIRE_DISPLAY_OFF 0xA5    /* 设置整个显示关闭 */ 
#define OLED_SET_PRECHARGE_PERIOD 0xD9  /* 设置预充电周期 */
#define OLED_SET_DISPLAY_START_LINE 0x40   /* 设置显示开始行（从Row0开始) */
#define OLED_SET_CONTRAST_CONTROL   0x81 /* 设置对比度控制 */
#define OLED_SET_DISPLAY_CLOCK_DIV  0xD5    /* 设置显示时钟分频比/振荡器频率 */



/**
 * Note: OLED的Page地址模式下，从高到低分为Page0-Page7 7个行，从左到右分为COL0-COL127 127个列
 * 列号高四位和低四位分别有专门的设置
 */
#define OLED_SET_PAGE_START_ADDR    0xB0    /* 设置行（页）起始地址(从Page0开始) */
#define OLED_SET_COLUMN_START_ADDR_H 0x10   /* 设置列号高四位 */ 
#define OLED_SET_COLUMN_START_ADDR_L 0x00   /* 设置列号低四位 */

void OLED_Init(void);
void OLED_Clear(void);
void OLED_ShowChar(uint8_t Line, uint8_t Column, char Char);
void OLED_ShowString(uint8_t Line, uint8_t Column, char *String);
void OLED_ShowNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
void OLED_ShowSignedNum(uint8_t Line, uint8_t Column, int32_t Number, uint8_t Length);
void OLED_ShowHexNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);
void OLED_ShowBinNum(uint8_t Line, uint8_t Column, uint32_t Number, uint8_t Length);

#endif
